from django.test import TestCase
from django.urls import resolve
from django.http import HttpRequest

from feed.views import feed_view

from feed.feed import make_recipe_from_rss

# Create your tests here.
class TestRecipeMaker(TestCase):
    def test_build_rss_recipe(self):
        dat = {
            'oldest_day': 7,
            'max_article': 50,
            'title': 'My NewFeed',
            'feeds': [{
                "title": "RSS TITLE",
                "url": "http://rssurl"
            }, {
                "title": "RSS TITLE2",
                "url": "http://rssurl2"
            }]
        }
        recipe = make_recipe_from_rss(dat)
        self.assertIn('title = \'%s\'' % dat['title'], recipe)
        self.assertIn('oldest_article = %d' % dat['oldest_day'], recipe)
        self.assertIn('max_articles_per_feed = %d' % dat['max_article'], recipe)
        for f in dat['feeds']:
            self.assertIn('(\'%s\'' % f['title'], recipe)
            self.assertIn('\'%s\')' % f['url'], recipe)


